﻿using System.Collections.Generic;
using WikiPlex;
using WikiPlex.Compilation;
using WikiPlex.Compilation.Macros;

namespace WikiMaml.Macros
{
    public class TopicMacro : IMacro
    {
        /// <summary>
        /// Gets the id of the macro.
        /// </summary>
        public string Id
        {
            get { return "Topic"; }
        }

        /// <summary>
        /// Gets the list of rules for the macro.
        /// </summary>
        public IList<MacroRule> Rules
        {
            get
            {
                return new List<MacroRule>
                           {
                               new MacroRule(
                                   @"(?si)(\{topic:conceptual=)([^}]+)(}).*?({topic})",
                                   new Dictionary<int, string>
                                    {
                                        {1, ScopeName.Remove},
                                        {2, MamlScopeName.ConceptualTopicBegin},
                                        {3, ScopeName.Remove},
                                        {4, MamlScopeName.ConceptualTopicEnd}
                                    }),
                                new MacroRule(
                                   @"(?si)(\{topic:walkthrough=)([^}]+)(}).*?({topic})",
                                   new Dictionary<int, string>
                                    {
                                        {1, ScopeName.Remove},
                                        {2, MamlScopeName.WalkthroughTopicBegin},
                                        {3, ScopeName.Remove},
                                        {4, MamlScopeName.WalkthroughTopicEnd}
                                    })
                           };
            }
        }
    }
}
